<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>缴费管理</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/static/js/global.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
	<script type="text/javascript"
            src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .main h5 a {
            position: absolute;
            right: 20px;
            font-size: 14px;
            bottom: 0px;
            display: inline-block;
            padding: 5px;
        }

        .table_list tbody tr {
            height: 35px;
            text-align: center;
        }
        .div1{
             margin-bottom: 20px;
			 overflow:hidden;
        }
        .td3{
			position: relative;
			width: 25%;
			float: left;
        }
        .imgStyle{
        	position: relative; 
			width: 80%;
        }
        .textLeft{
            position: absolute;
	   		z-index: 1;
		    top: 40%;
			left:0px;
		    width: 26%;
		    text-align: center;
		    font-size: 1.3em;
		    color: black;
	    }
	    .textRight{
            position: absolute;
	   		z-index: 1;
		    top: 40%;
		    width: 53%;
		    left: 26%;
		     font-size: 1.3em;
		    text-align: center;
		    color: white;
	    }
		.left ul li{
			
			*line-height:40px;
			*background:#484848;
			*padding-left:20px;
		}
		
		.left ul li a, .left ul li a:hover{
			*color:#fff;
		}
		.wrapper{
			*margin-left:270px;
		}
		.form-group{
			*overflow: hidden;
		}
		.btn{
			*width:50px;
		}
		.lt{
			float:left;
		}
		.input-group{
			overflow:hidden;
		}
		.col-md-1 {
			*padding-left:0;
			*padding-right:10px;
		}
		.ui-pg-button{
			*background:#ccc;
		}
		.selectlabe1{
			width:100px !important;
		}
		.selectdivs{
			width:140px !important;
		}
    </style>
</head>
<body view="menu-item-4142">
<jsp:include page="../../top.jsp"></jsp:include>
<div class="right">
 	<div class="wrapper">
        <div class="div1" id="countAll">
	        <div class="td3" id="conunt1">
	        	<div>
	        		<img class="imgStyle" alt="总户数" title="总户数" src="${pageContext.request.contextPath}/static/images/propertyPay/blue.png">
	        		<div class="textLeft"><font>总户数</font></div>
	        		<div class="textRight"><font id="countuser"></font></div>
	        	</div>
	        </div>
	        <div class="td3" >
	        	<div>
	        		<img class="imgStyle" alt="已缴户数" title="总户数" src="${pageContext.request.contextPath}/static/images/propertyPay/yellow.png">
	        		<div class="textLeft"><font>已缴户数</font></div>
	        		<div class="textRight"><font id="payuser"></font></div>
	        		</div>
	        </div>
	        <div class="td3">
	        	<div >
	        		<img class="imgStyle" alt="总金额" title="总户数" src="${pageContext.request.contextPath}/static/images/propertyPay/green.png">
	        		<div class="textLeft"><font>总金额</font></div>
	        		<div class="textRight"><font id="countmoney"></font></div>
	        		</div>
	        </div>
	        <div class="td3">
	        	<div >
	        	<img class="imgStyle" alt="已缴金额" title="总户数" src="${pageContext.request.contextPath}/static/images/propertyPay/navy.png">
	        		<div class="textLeft"><font>已缴金额</font></div>
	        		<div class="textRight"><font id="paymoney"></font></div>
	        	</div>
	        </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">
                <span><strong>查询条件</strong></span>

                <div class="ibox-tools">
                    <a class="collapse-link"> <i class="fa fa-chevron-down"></i></a>
                    <a class="collapse-link  d-n"> <i class="fa fa-chevron-up"></i></a>
                </div>
            </div>
            <div class="panel-body" id="selectQuery">
                <form class="form-horizontal">
                       <c:if test="${userRole == 1 || userRole == 2  || userRole == 21}">
		                <div class="form-group">
		               		<label class="selectlabe1 col-md-1 lt form-lable">公司名称：</label>
		                    <div class="selectdivs col-md-3 lt">
		                        <select name="agtCode" id="agtCode" class="form-control col-md-1"></select>
		                    </div>
		                    
		                    <label class="selectlabe2 col-md-1 lt form-lable" >所属区域：</label>
				            <div id="region" class="col-md-3 lt" style="width:140px; *+width:120px;padding-left: 0px;">
				                <script type="text/javascript">
				                    loadCity();
				                </script>
				            </div>
		         		</div>
		         		<div class="form-group">
	                        <label class="selectlabe1 col-md-1 lt form-lable" style="width: 90px;">小区名称：</label>
		                    <div class="selectdivs col-md-3 lt" >
		                        <select name="communityId" id="communityId" class="form-control col-md-1"></select>
		                    </div>
				            <label class="selectlabe2 col-md-1 lt form-lable" style="width: 90px;">缴费名称：</label>
		                    <div class="selectdivs col-md-3 lt" >
		                        <select name="itemName" id="itemName" class="form-control col-md-1"></select>
		                    </div>
	                        <div class="col-md-1 form-action lt">
	                            <button class="btn btn-success form-control" id="query">查询</button>
	                        </div>
	                        <div class="col-md-1 form-action lt">
	                            <button class="btn btn-success form-control" id="resetForm">清空</button>
	                        </div>
                   		</div>
         			</c:if> 
         			<c:if test="${userRole == 3 || userRole == 4}">
		         		<div class="form-group">
                      		<label class="selectlabe1 col-md-1 lt form-lable" style="width: 90px;">小区名称：</label>
		                    <div class="selectdivs col-md-3 lt" >
		                        <select name="communityId" id="communityId" class="form-control col-md-1"></select>
		                    </div>
                      		<label class="selectlabe2 col-md-1 lt form-lable" >所属区域：</label>
				            <div id="region" class="col-md-3 lt" style="width:140px ;*+width: 120px;padding-left: 0px;">
				                <script type="text/javascript">
				                    loadCity();
				                </script>
				            </div>
				            <label class="selectlabe2 col-md-1 lt form-lable" style="width: 90px;">缴费名称：</label>
		                    <div class="selectdivs col-md-3 lt" >
		                        <select name="itemName" id="itemName" class="form-control col-md-1"></select>
		                    </div>
	                        <div class="col-md-1 form-action lt">
	                            <button class="btn btn-success form-control" id="query">查询</button>
	                        </div>
	                        <div class="col-md-1 form-action lt">
	                            <button class="btn btn-success form-control" id="resetForm">清空</button>
	                        </div>
                   		</div>
         			</c:if>
         			<c:if test="${userRole == 5 || userRole == 6}">
		         		<div class="form-group">
                        	<label class="selectlabe1 col-md-1 lt form-lable" style="width: 90px;">缴费名称：</label>
		                    <div class="selectdivs col-md-3 lt" >
		                        <select name="itemName" id="itemName" class="form-control col-md-1"></select>
		                    </div>
	                        <div class="col-md-1 form-action lt">
	                            <button class="btn btn-success form-control" id="query">查询</button>
	                        </div>
	                        <div class="col-md-1 form-action lt">
	                            <button class="btn btn-success form-control" id="resetForm">清空</button>
	                        </div>
                   		</div>
         			</c:if>
         			
                </form>
            </div>
        </div>
	    <div class="jqGrid_wrapper">
	        <div id="jqGrid_operation" class="jg-grid">
	            <div class="jqGrid_operation" id="action"></div>
	        </div>
	        <table id="jqGrid"></table>
	        <div id="jqGrid_paper"></div>
	    </div>
	</div>
</div>
<script>
    $(document).ready(
            function () {
            	var countAllHeight = $("#conunt1").outerHeight();
            	$("#countAll").attr("style","height:"+countAllHeight+"px");	
				var ifUpdate = false;
				var ifUpdateWater = false;
				var ifUpdateStop = false;

				$.post("${pageContext.request.contextPath}/admin/propertyPay_countUserPay.action?type=${type}",function (data) {
					$("#countuser").html(data.COUNTUSER+"户");
					$("#countmoney").html(data.COUNTMONEY+"元");
					$("#payuser").html(parseInt(data.PAYUSER)+"户");
					$("#paymoney").html(getNum(data.PAYMONEY)+"元");
		        }, "json");
				
            	$.ajax({
                    type: "POST",
                    async: false,
                    url: '/admin/auth_buttons.action',
                    data: {"url":window.location.pathname,"type":'${type}'},
                    success: function (data) {
                        data = eval("(" + data + ")");
                        for (var i in data) {
                            var action = data[i].mName;
                            switch (action) {
                            	case "物业缴费新增":
								if('${userRole}'=='5' ||'${userRole}'=='6'){
	                                $("#action").append("<a id=\"add\"><i class=\"glyphicon glyphicon-plus\"></i>新增物业缴费</a>");
								}
                                $("#add").click(function () {
                                    layer.open({	
                                        type: 2,
                                        title: ['新增物业缴费', 'font-weight:bold'],
                                        shadeClose: true, //点击遮罩关闭层
                                        area: ['800px', '230px'],
                                        scrollbar: false,
                                        content: '${pageContext.request.contextPath}/admin/propertyPay_addMenuView.action?type=1',
                                        btn: ['提交', '取消'],
                                        yes: function (index, layero) {
                                        	layer.confirm('确认操作?', function () {
                                             var options = {
                                                success: function (data) {
                                                    data = JSON.parse(data);
                                                    if (data.code == 1) {
                                                        layer.alert(data.msg, function () {
                                                            layer.closeAll();
                                                            location.reload();
                                                        });
                                                    } else {
                                                        layer.alert(data.msg);
                                                    }
                                                }
                                            };
                                            
                                                $("#layui-layer-iframe" + index).contents().find("#form").ajaxForm(options);
                                                $("#layui-layer-iframe" + index).contents().find("#form").submit();
                                            });
                                        },
                                        cancel: function (index, layero) {
                                            layer.close(index);
                                        }
                                    });
                                });
                                break;
                            	case "水费新增":
    								if('${userRole}'=='5' ||'${userRole}'=='6'){
    	                                $("#action").append("<a id=\"add\"><i class=\"glyphicon glyphicon-plus\"></i>新增水费缴费</a>");
    								}
                                    $("#add").click(function () {
                                        layer.open({	
                                            type: 2,
                                            title: ['新增水费缴费', 'font-weight:bold'],
                                            shadeClose: true, //点击遮罩关闭层
                                            area: ['800px', '230px'],
                                            scrollbar: false,
                                            content: '${pageContext.request.contextPath}/admin/propertyPay_addMenuView.action?type=2',
                                            btn: ['提交', '取消'],
                                            yes: function (index, layero) {
                                            	layer.confirm('确定新增？将建立所有住户的缴费', function () {
	                                                var options = {
	                                                    success: function (data) {
	                                                        data = JSON.parse(data);
	                                                        if (data.code == 1) {
	                                                            layer.alert(data.msg, function () {
	                                                                layer.closeAll();
	                                                                location.reload();
	                                                            });
	                                                        } else {
	                                                            layer.alert(data.msg);
	                                                        }
	                                                    }
	                                                };
                                                
	                                                $("#layui-layer-iframe" + index).contents().find("#form").ajaxForm(options);
	                                                $("#layui-layer-iframe" + index).contents().find("#form").submit();
                                                });
                                            },
                                            cancel: function (index, layero) {
                                                layer.close(index);
                                            }
                                        });
                                    });
                                    break;
                            	case "停车费新增":
    								if('${userRole}'=='5' ||'${userRole}'=='6'){
    	                                $("#action").append("<a id=\"add\"><i class=\"glyphicon glyphicon-plus\"></i>新增停车费缴费</a>");
    								}
                                    $("#add").click(function () {
                                        layer.open({	
                                            type: 2,
                                            title: ['新增停车费缴费', 'font-weight:bold'],
                                            shadeClose: true, //点击遮罩关闭层
                                            area: ['800px', '230px'],
                                            scrollbar: false,
                                            content: '${pageContext.request.contextPath}/admin/propertyPay_addMenuView.action?type=3',
                                            btn: ['提交', '取消'],
                                            yes: function (index, layero) {
                                            layer.confirm('确定新增？将建立所有住户的缴费', function () {
                                                 var options = {
                                                    success: function (data) {
                                                        data = JSON.parse(data);
                                                        if (data.code == 1) {
                                                            layer.alert(data.msg, function () {
                                                                layer.closeAll();
                                                                location.reload();
                                                            });
                                                        } else {
                                                            layer.alert(data.msg);
                                                        }
                                                    }
                                                };
	                                                $("#layui-layer-iframe" + index).contents().find("#form").ajaxForm(options);
	                                                $("#layui-layer-iframe" + index).contents().find("#form").submit();
                                                });
                                            },
                                            cancel: function (index, layero) {
                                                layer.close(index);
                                            }
                                        });
                                    });
                                    break;
                            	case "物业缴费修改":
                            		ifUpdate = true;
                            	break;
                            	case "水费修改":
                            		ifUpdateWater = true;
                            	break;
                            	case "停车费修改":
                            		ifUpdateStop = true;
                            	break;
                            }
                        }
                    }
                });
                $.jgrid.defaults.styleUI = "Bootstrap";
                $("#jqGrid").jqGrid(
                        {
                            url: "${pageContext.request.contextPath}/admin/propertyPay_page.action?type=${type}",
                            mtype: 'POST',
                            datatype: "json",
                            height: 350,
                            autowidth: true,
                            shrinkToFit: true,
                            rowNum: 10,
                            rowList: [10, 20, 30],
                            colNames: ['序号', '缴费名称', '总户数', '已缴户数', '总金额', '已缴金额',
                                '创建时间', '创建人', '修改时间', '修改人','操作'],
                            colModel: [{
                                name: "SID",
                                index: "SID",
                                key: true,
                                hidden: true
                            }, {
                                name: 'ITEM_NAME',
                                index: 'ITEM_NAME',
                                formatter: function (cellvalue, options, rawObject) {
                                    if(!cellvalue){
                                    	return ''
                                    }else{
                                    	return '<a style="border-bottom:1px solid #337ab7;" href="${pageContext.request.contextPath}/admin/propertyPay_listPropertyPayView.action?type=${type}&sid='+rawObject.SID+'">'+cellvalue+'</a>';
                                    }
                                }
                            },{
                                name: "COUNTUSER",
                                index: "COUNTUSER"
                            }, {
                                name: 'PAYUSER',
                                index: 'PAYUSER'
                                
                            },{
                                name: 'COUNTMONEY',
                                index: 'COUNTMONEY'
                               
                            },{
                                name: 'PAYMONEY',
                                index: 'PAYMONEY'
                                
                            }, {
                                name: "CTIME",
                                index: "CTIME"
                            },{
                                name: 'CUSERNAME',
                                index: 'CUSERNAME'
                               
                            },{
                                name: 'UTIME',
                                index: 'UTIME'
                                
                            }, {
                                name: "UUSERNAME",
                                index: "UUSERNAME"
                            }, {
                                name: "CZ",
                                index: "CZ",
                                width: 120,
                                formatter: function (cellvalue, options, rawObject) {
                                    switch ('${type}') {
									case '1':
										if(cellvalue=='no' || ifUpdate==false) {
	                                    	return '';
	                                    }else {
	                                        var retur='<input type="button" style="padding: 2px 10px;margin-left: 5px;" class="btn btn-success" value="编辑 " onclick="edit('+rawObject.SID+')"/>';
	                                        return retur;
	                                   	}
										break;
									case '2':
										if(cellvalue=='no' || ifUpdateWater==false) {
	                                    	return '';
	                                    }else {
	                                        var retur='<input type="button" style="padding: 2px 10px;margin-left: 5px;" class="btn btn-success" value="编辑 " onclick="edit('+rawObject.SID+')"/>';
	                                        return retur;
	                                   	}
										break;
									case '3':
										if(cellvalue=='no' || ifUpdateStop==false) {
	                                    	return '';
	                                    }else {
	                                        var retur='<input type="button" style="padding: 2px 10px;margin-left: 5px;" class="btn btn-success" value="编辑 " onclick="edit('+rawObject.SID+')"/>';
	                                        return retur;
	                                   	}
										break;

									default:
										return '';
										break;
									}
                                	if(cellvalue=='no' || (ifUpdate==false && ifUpdateWater==false && ifUpdateStop==false)){
                                    	return '';
                                    }else {
                                        var retur='<input type="button" style="padding: 2px 10px;margin-left: 5px;" class="btn btn-success" value="编辑 " onclick="edit('+rawObject.SID+')"/>';
                                        return retur;
                                   	}
                                }
                            }],
                            sortname: 't.sid',
                            sortorder: 'desc',
                            rownumbers: true,
                            jsonReader: {
                                root: 'rows',
                                page: "page",
                                total: 'total',
                                records: "records",
                                repeatitems: false
                            },
                            pager: "#jqGrid_paper",
                            viewrecords: true,
                            multiselect: true,
                            hidegrid: false,
                            loadComplete: function(){
                        		var re_records = Number($("#jqGrid").getGridParam('records'));
                        		var page = Number($("#jqGrid").getGridParam('page'));
                        		var rows=Number($("#jqGrid").getGridParam('rowNum'));
                        		var num = re_records-(page-1)*rows;
                        		if(num < rows)
                        		{
                        			for(var i=num;i<rows;i++){
                        				$("#jqGrid").jqGrid("addRowData",(i+1),
                                				{ "SID":"", "ITEM_NAME":"","CZ":"no"}
                        				,"");
                        			}
                        			$(".ui-paging-info").html(re_records-num+1 +" - "+re_records+"　共 "+re_records+" 条");
                        		}
                        		doResize();//自适应屏幕大小
                        	}
                        });
                if('${userRole}' == '1' || '${userRole}' == '2' || '${userRole}' == '21'){
	                $.post("${pageContext.request.contextPath}/admin/tagent_list.action", function (data) {
			            $("#agtCode").empty();
			            $("#agtCode").append("<option value=''>请选择公司</option>");
			            for (var i = 0; i < data.length; i++) {
			                $("#agtCode").append("<option value='" + data[i].agtCode + "'>" + data[i].agtName + "</option>");
			            }
			            $("#agtCode").select2({
			                "placeholder": "请选择公司",
			                "width": "100%"
			            })
			            $("#agtCode").change(function () {
			            	var data = $(this).val();
			            	$.post("${pageContext.request.contextPath}/admin/tcommunity_list.action", {"agtCode": data},function (data) {
					            $("#communityId").empty();
					            $("#communityId").append("<option value=''>请选择社区</option>");
					            for (var i = 0; i < data.length; i++) {
					                $("#communityId").append("<option value='" + data[i].sid + "'>" + data[i].communityName + "</option>");
					            }
					            $("#communityId").select2({
					                "placeholder": "请选择社区",
					                "width": "100%"
					            })
					            
					        }, "json");
			            })
			        }, "json");
                }else if('${userRole}' == '3' || '${userRole}' == '4' ){
                	$.post("${pageContext.request.contextPath}/admin/tcommunity_list.action", 
                        function (data) {
			            $("#communityId").empty();
			            $("#communityId").append("<option value=''>请选择社区</option>");
			            for (var i = 0; i < data.length; i++) {
			                $("#communityId").append("<option value='" + data[i].sid + "'>" + data[i].communityName + "</option>");
			            }
			            $("#communityId").select2({
			                "placeholder": "请选择社区",
			                "width": "100%"
			            })
			        }, "json");
                }
                $("#communityId").change(function () {
	            	var data = $(this).val();
	            	$.post("${pageContext.request.contextPath}/admin/propertyPay_list.action", {"communityId": data,"type":'${type}'},function (data) {
			            $("#itemName").empty();
			            $("#itemName").append("<option value=''>请选择缴费名称</option>");
			            for (var i = 0; i < data.length; i++) {
			                $("#itemName").append("<option value='" + data[i].sid + "'>" + data[i].itemName + "</option>");
			            }
			            $("#itemName").select2({
			                "placeholder": "请选择缴费名称",
			                "width": "100%"
			            })
			            
			        }, "json");
	            })
                <!--查询-->
                jQuery("#query").click(query);
                jQuery("#resetForm").click(resetForm);
            });

    <!--刷新jqGrid表格数据-->
    function refreshGrid() {
        $("#jqGrid").trigger("reloadGrid");
    }
    function resetForm() {
        location.reload();
        return false;
    }
    function query() {
    	 var agtCode = $("#agtCode").val();
         var communityId = $("#communityId").val();
         var areaCode;
 		if('${userRole}' != 5 && '${userRole}' != 6){
 	        var selects=document.getElementsByName('location');
 	        areaCode = selects[0].value;
 		}
        var itemName = $("#itemName").val();
        $("#jqGrid").jqGrid('setGridParam', {
            url: "${pageContext.request.contextPath}/admin/propertyPay_page.action",
            postData: {
                'type':'${type}',
            	'agtCode': agtCode,
                'communityId': communityId,
                'areaCode': areaCode,
                'itemName': itemName
            }, //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入*/
        return false;
    }
    $("#communityId").select2({
        "placeholder": "请选择社区",
        "minimumResultsForSearch":-1
    })
     $("#itemName").select2({
        "placeholder": "请选择缴费",
        "minimumResultsForSearch":-1
    })
    function edit(sid){
    	layer.open({
            type: 2,
            title: ['修改缴费名称', 'font-weight:bold'],
            shadeClose: true, //点击遮罩关闭层
            area: ['800px', '230px'],
            scrollbar: false,
            content: '${pageContext.request.contextPath}/admin/propertyPay_editMenuView.action?sid='+sid,
            btn: ['提交', '取消'],
            yes: function (index, layero) {
                var options = {
                    success: function (data) {
                        data = JSON.parse(data);
                        if (data.code == 1) {
                            layer.alert(data.msg, function () {
                                layer.closeAll();
                                refreshGrid();
                            });
                        } else {
                            layer.alert(data.msg);
                        }
                    }
                };
                $("#layui-layer-iframe" + index).contents().find("#form").ajaxForm(options);
                $("#layui-layer-iframe" + index).contents().find("#form").submit();
            },
            cancel: function (index, layero) {
                layer.close(index);
            }
        });
      }
   
function getNum(f){
	    
	    var f = Math.round(f*100)/100;    
	    var s = f.toString();    
	    var rs = s.indexOf('.');    
	    if (rs < 0) {    
	        rs = s.length;    
	        s += '.';    
	    }    
	    while (s.length <= rs + 2) {    
	        s += '0';    
	    }    
	    return s;
};

window.onload=function(){
	
	function BrowserType(){
		//获取浏览器的userAgent代理号；
		var userAgent=navigator.userAgent;
		
		//判断是否是Opera浏览器
		var isOpera=userAgent.indexOf("Opera")>-1;
		//判断是否是IE浏览器
		var isIE=userAgent.indexOf("compatible")>-1 && userAgent.indexOf("MSIE")>-1 && !isOpera;
		//判断是否是IE7浏览器
		if(isIE){
			var relIE=new RegExp("MSIE(\\d+\\.\\d+);");
			
			relIE.test(userAgent);
			var arr=userAgent.split(";")
			var flEVersion=arr[1].indexOf("7");
			if(flEVersion>-1){
				var $td=$(".jqgrid-rownum")[0];
				$td.style.width="0";
				$tr=$("thead tr th");
				$td=$("tbody tr td");
				var len=$tr.length;
				for(var i=0;i<len;i++){
					$tr[i].style.width=10+"px";
					$td[i].style.width=10+"px";
				};
			}
		}
	};
	BrowserType();
};
if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length >>> 0;
    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;
    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
};

</script>
</body>
</html>
